﻿$(document).ready(function () {
    $(".single").colorbox();
    $(".popcheckexist").colorbox({ width: "60%", height: "80%", inline: true, href: "#divcheckexistaddict" });
    //$("#ckfullname").val($("#drcfullname").val());
});

$(document).ready(function () {
    $(".single").colorbox();
    $(".popupviewdetails").colorbox({ width: "1024px", height: "80%", inline: true, href: "#divviewdetailscontent" });   
});
$(document).ready(function () {
    $(".single").colorbox();
    $(".popupdateform").colorbox({ width: "1024px", height: "80%", inline: true, href: "#divupdateaddictcontent" });
    //$("#ckfullname").val($("#drcfullname").val());
});

$(document).ready(function () {
    $(".single").colorbox();
    $(".popupdateurl").colorbox({ width: "1024px", height: "80%", inline: true, href: "#divupdateaddictcontent" });
    //$("#ckfullname").val($("#drcfullname").val());
});

function rewriteUpdatePanel(drugid) {
    $("#divviewdetailscontent").html("");
    $("#divviewdetailscontent").html(SODC.IDIS.DrugAddict.ListViewDrugAddict.GetUpdateAddictForm(drugid).value);
}

function fillolddata() {
    $("#ckCMT").val($("#drcCMT").val());
    $("#ckfullname").val($("#drcfullname").val());
    $("#ckbirthdate").val($("#drcbirthdate").val());
    $("#cknguyenquan").val($("#drcnguyenquan").val());
}

function ClientAddNewDrugAddictResetAllField() {
    document.getElementById("drcngaynhan").value = '';
    document.getElementById("drcfullname").value = '';
    $("#drcrbtmale").attr('checked', true);
    document.getElementById("drcbirthdate").value = '';
    document.getElementById("drcCMT").value = '';
    document.getElementById("drcngaycap").value = '';
    document.getElementById("drcnoicap").value = '';
    document.getElementById("drcnguyenquan").value = '';
    document.getElementById("drcchoohn").value = '';
    document.getElementById("drctendaithe").value = '';
    document.getElementById("drcnoidk").value = '';
    $("#drckotongiao").attr('checked', true);
    document.getElementById("drccheckdangvien").checked = false;
    document.getElementById("drcchecktienan").checked = false;
    document.getElementById("drccheckxuphat").checked = false;
    $("#drcrbtkinh").attr('checked', true);
    $("#drcvietnam").attr('checked', true);
    document.getElementById("drcdangvien").checked = false;
    document.getElementById("drcthanhphan").selectedIndex = 0;
    document.getElementById("drcvieclam").selectedIndex = 0;
    document.getElementById("drctrangthai").selectedIndex = 0;
    document.getElementById("drchinhthuccn").selectedIndex = 0;
    document.getElementById("drcnoicainghien").value = "";
    document.getElementById("drcbienphap").selectedIndex = 0;

    $("#drcchuacainghien").attr('checked', true);
    $("#drctainoicutru").attr('checked', true);
    document.getElementById("drchotrosaucn").selectedIndex = 0;
    document.getElementById("drcbatdaunghien").value = '';
    document.getElementById("drcloaimtsd").selectedIndex = 0;
    document.getElementById("drcquatrinhxd").value = '';
    document.getElementById("drcfullname").focus();
}
function checkdate(date) {
    var validformat = /^\d{2}\/\d{2}\/\d{4}$/;
    var returnval = false;
    if (!validformat.test(date))
        alert("Nhập sai định dạng ngày tháng.");
    else {
        var monthfield = date.split("/")[0];
        var dayfield = date.split("/")[1];
        var yearfield = date.split("/")[2];
        var dayobj = new Date(yearfield, monthfield - 1, dayfield);
        if ((dayobj.getMonth() + 1 != monthfield) || (dayobj.getDate() != dayfield) || (dayobj.getFullYear() != yearfield))
            alert("Vui lòng nhập lại ngày tháng theo định dạng tháng/ngày/năm.");
        else
            returnval = true;
    }
    return returnval;
}

function ClientSideCheckValidate() {
    ngaynhan = document.getElementById("drcngaynhan").value;
    if (ngaynhan == "") {
        alert("Chưa nhập ngày nhận!");
        document.getElementById("drcngaynhan").focus();
        return;
    }
    checkngaynhan = checkdate(ngaynhan);
    if (checkngaynhan == false) {
        document.getElementById("drcngaynhan").focus();
        document.getElementById("drcngaynhan").select();
        return;
    }
    fullname = document.getElementById("drcfullname").value;
    if (fullname == "") {
        alert("Chưa nhập họ tên người nghiện!");
        document.getElementById("drcfullname").focus();
        return;
    }
    checksex = $('input[name=rbtchecksex]:checked').val();
    birthdate = document.getElementById("drcbirthdate").value;
    if (birthdate == "") {
        alert("Chưa nhập ngày sinh người nghiện!");
        document.getElementById("drcbirthdate").focus();
        return;
    }
    checkbirthdate = checkdate(birthdate);
    if (checkbirthdate == false) {

        document.getElementById("drcbirthdate").select();
        return;
    }
    var cmt = document.getElementById("drcCMT").value;
          if (cmt != "") {
            var year = /^[0-9]+$/;
            if (year.test(cmt) == false) {
                alert("Nhập sai định dạng số chứng minh thư!");
                document.getElementById("drcCMT").select();
                return;
            }  
        }
    ngaycap = document.getElementById("drcngaycap").value;
    noicap = document.getElementById("drcnoicap").value;
    nguyenquan = document.getElementById("drcnguyenquan").value;
    if (nguyenquan == "") {
        alert("Chưa nhập nguyên quán người nghiện!");
        document.getElementById("drcnguyenquan").focus();
        return;
    }
    noidk = document.getElementById("drcnoidk").value;
    if (noidk == "") {
        alert("Chưa nhập nơi đăng ký hộ khẩu thường trú của người nghiện!");
        document.getElementById("drcnoidk").focus();
        return;
    }
    choohn = document.getElementById("drcchoohn").value;
    tendaithe = document.getElementById("drctendaithe").value;    
    tongiao = $('input[name=drcdantoc]:checked').val();
    condangvien = document.getElementById("drccheckdangvien").checked;
    tienan = document.getElementById("drcchecktienan").checked;
    xuphat = document.getElementById("drccheckxuphat").checked;
    checkdantoc = $('input[name=drcdantoc]:checked').val();
    checkquoctich = $('input[name=drcquoctich]:checked').val();    
    checkdangvien = document.getElementById("drcdangvien").checked;
    thanhphan = document.getElementById("drcthanhphan").options[document.getElementById("drcthanhphan").selectedIndex].value;
    vieclam = document.getElementById("drcvieclam").options[document.getElementById("drcvieclam").selectedIndex].value;
    trangthai = document.getElementById("drctrangthai").options[document.getElementById("drctrangthai").selectedIndex].value;
    checktrangthaicn = $('input[name=drctrangthaicainghien]:checked').val();
    hinhthuccn = document.getElementById("drchinhthuccn").options[document.getElementById("drchinhthuccn").selectedIndex].value;
    noicainghien = document.getElementById("drcnoicainghien").value;
    bienphap = document.getElementById("drcbienphap").options[document.getElementById("drcbienphap").selectedIndex].value;
    checkqlsaucn = $('input[name=drcqlsaucainghien]:checked').val();
    hotrosaucn = document.getElementById("drchotrosaucn").options[document.getElementById("drchotrosaucn").selectedIndex].value;
    nambdnghien = document.getElementById("drcbatdaunghien").value;
    if (nambdnghien == "") {
        alert("Chưa nhập năm người nghiện bắt đầu nghiện!");
        document.getElementById("drcbatdaunghien").focus();
        return;
    }
    var year = /^[0-9]{4}$/;
    if (year.test(nambdnghien) == false) {
        alert("Nhập sai định dạng năm bắt đầu nghiện!");
        document.getElementById("drcbatdaunghien").select();
        return;
    }
    loaimtsd = document.getElementById("drcloaimtsd").options[document.getElementById("drcloaimtsd").selectedIndex].value;
    quatrinhxd = document.getElementById("drcquatrinhxd").value;
    retVal = SODC.IDIS.DrugAddict.AddNewDrugAddict.ServerSideAddNewDrugAddict(ngaynhan, fullname, checksex, birthdate, cmt, ngaycap, noicap, nguyenquan, choohn, tendaithe, noidk, tongiao, condangvien, tienan, xuphat, checkdantoc, checkquoctich, checkdangvien, thanhphan, vieclam, trangthai, hinhthuccn, noicainghien, bienphap, checktrangthaicn, checkqlsaucn, hotrosaucn, nambdnghien, loaimtsd, quatrinhxd).value;
    if (retVal.indexOf("ERROR") != -1) {
        alert(retVal);
        return;
    }
    alert(retVal);
    ClientAddNewDrugAddictResetAllField();
}

function ClientSideCheckUpdateValidate(AddictId) {
    ngaynhan = document.getElementById("upngaynhan").value;
    if (ngaynhan == "") {
        alert("Chưa nhập ngày nhận!");
        document.getElementById("upngaynhan").focus();
        return;
    }
    checkngaynhan = checkdate(ngaynhan);
    if (checkngaynhan == false) {
        document.getElementById("upngaynhan").focus();
        document.getElementById("upngaynhan").select();
        return;
    }
    fullname = document.getElementById("upfullname").value;
    if (fullname == "") {
        alert("Chưa nhập họ tên người nghiện!");
        document.getElementById("upfullname").focus();
        return;
    }
    checksex = $('input[name=rbtchecksex]:checked').val();
    birthdate = document.getElementById("upbirthdate").value;
    if (birthdate == "") {
        alert("Chưa nhập ngày sinh người nghiện!");
        document.getElementById("upbirthdate").focus();
        return;
    }
    checkbirthdate = checkdate(birthdate);
    if (checkbirthdate == false) {

        document.getElementById("upbirthdate").select();
        return;
    }
    cmt = document.getElementById("upCMT").value;
        if (cmt != "") {
            var year = /^[0-9]+$/;
            if (year.test(cmt) == false) {
                alert("Nhập sai định dạng số chứng minh thư!");
                document.getElementById("upCMT").select();
                return;
            }  
        }
    ngaycap = document.getElementById("upngaycap").value;
    noicap = document.getElementById("upnoicap").value;
    nguyenquan = document.getElementById("upnguyenquan").value;
    if (nguyenquan == "") {
        alert("Chưa nhập nguyên quán người nghiện!");
        document.getElementById("upnguyenquan").focus();
        return;
    }
    noidk = document.getElementById("upnoidk").value;
    if (noidk == "") {
        alert("Chưa nhập nơi đăng ký hộ khẩu thường trú của người nghiện!");
        document.getElementById("upnoidk").focus();
        return;
    }
    choohn = document.getElementById("upchoohn").value;
    tendaithe = document.getElementById("uptendaithe").value;
    
    tongiao = $('input[name=updantoc]:checked').val();
    condangvien = document.getElementById("upcheckcondangvien").checked;
    tienan = document.getElementById("upchecktienan").checked;
    xuphat = document.getElementById("upcheckxuphat").checked;
    //right col
    checkdantoc = $('input[name=updantoc]:checked').val();
    checkquoctich = $('input[name=upquoctich]:checked').val();
    checkdangvien = document.getElementById("updangvien").checked;
    thanhphan = document.getElementById("upthanhphan").options[document.getElementById("upthanhphan").selectedIndex].value;
    vieclam = document.getElementById("upvieclam").options[document.getElementById("upvieclam").selectedIndex].value;
    trangthai = document.getElementById("uptrangthai").options[document.getElementById("uptrangthai").selectedIndex].value;
    checktrangthaicn = $('input[name=uptrangthaicainghien]:checked').val();
    hinhthuccn = document.getElementById("uphinhthuccn").options[document.getElementById("uphinhthuccn").selectedIndex].value;
    noicainghien = document.getElementById("upnoicainghien").value;
    bienphap = document.getElementById("upbienphap").options[document.getElementById("upbienphap").selectedIndex].value;
    checkqlsaucn = $('input[name=upqlsaucainghien]:checked').val();
    hotrosaucn = document.getElementById("uphotrosaucn").options[document.getElementById("uphotrosaucn").selectedIndex].value;
    nambdnghien = document.getElementById("upbatdaunghien").value;
    if (nambdnghien == "") {
        alert("Chưa nhập năm người nghiện bắt đầu nghiện!");
        document.getElementById("upbatdaunghien").focus();
        return;
    }
    var year = /^[0-9]{4}$/;
    if (year.test(nambdnghien) == false) {
        alert("Nhập sai định dạng năm bắt đầu nghiện!");
        document.getElementById("upbatdaunghien").select();
        return;
    }
    loaimtsd = document.getElementById("uploaimtsd").options[document.getElementById("uploaimtsd").selectedIndex].value;
    quatrinhxd = document.getElementById("upquatrinhxd").value;
    retVal = SODC.IDIS.DrugAddict.UpdateDrugAddict.ServerSideUpdateDrugAddict(AddictId, ngaynhan, fullname, checksex, birthdate, cmt, ngaycap, noicap, nguyenquan, choohn, tendaithe, noidk, tongiao, condangvien, tienan, xuphat, checkdantoc, checkquoctich, checkdangvien, thanhphan, vieclam, trangthai, hinhthuccn, noicainghien, bienphap, checktrangthaicn, checkqlsaucn, hotrosaucn, nambdnghien, loaimtsd, quatrinhxd).value;
    if (retVal.indexOf("ERROR") != -1) {
        alert(retVal);
        return;
    }
    alert(retVal);
    window.close();
}

function ClientCheckExistDrugAddict() {
    fullname = document.getElementById("drcfullname").value;
    checksex = $('input[name=rbtchecksex]:checked').val();
    birthdate = document.getElementById("drcbirthdate").value;
    cmt = document.getElementById("drcCMT").value;
    nguyenquan = document.getElementById("drcnguyenquan").value;
    var RetValue = SODC.IDIS.DrugAddict.AddNewDrugAddict.GetShowCheckExistAddictForm(cmt, FullName, checksex, birthdate, nguyenquan).value;
    if (RetValue.indexOf("ERROR") != -1) {
        alert(RetValue);
        return;
    }
    document.getElementById("divcheckexistaddict").innerHTML = RetValue;
}

function ClientDeleteDrugAddict(DrugAddictId, belongsite, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    Msg = SODC.IDIS.DrugAddict.ListViewDrugAddict.GetConfirmDeleteMsg().value;
    if (confirm(Msg) == false) return;
    RetValue = SODC.IDIS.DrugAddict.ListViewDrugAddict.ServerSideDeleteDrugAddict(DrugAddictId).value;
    if (RetValue.indexOf("ERROR") != -1) {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    RealFilterFunc(belongsite, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript);

}

function SearchDrugAddictInfo(belongsite, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    Addictcode = document.getElementById("DrugAddictCode").value;
    AddictName = document.getElementById("DrugAddictName").value;
    AddictIdent = document.getElementById("DrugAddictIdent").value;
    AddictOrigin = document.getElementById("DrugAddictOrigin").value;
    retValue = SODC.IDIS.DrugAddict.ListViewDrugAddict.GetHtml(belongsite, Addictcode, AddictName, AddictIdent, AddictOrigin, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("listdrugpersonscontent").innerHTML = retValue;
}

function RealFilterFunc(belongsite, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    Addictcode = document.getElementById("DrugAddictCode").value;
    AddictName = document.getElementById("DrugAddictName").value;
    AddictIdent = document.getElementById("DrugAddictIdent").value;
    AddictOrigin = document.getElementById("DrugAddictOrigin").value;
    retValue = SODC.IDIS.DrugAddict.ListViewDrugAddict.GetHtml(belongsite, Addictcode, AddictName, AddictIdent, AddictOrigin, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("listdrugpersonscontent").innerHTML = retValue;
}

function Jumppageslistdrugpersons(belongsite, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    Addictcode = document.getElementById("DrugAddictCode").value;
    AddictName = document.getElementById("DrugAddictName").value;
    AddictIdent = document.getElementById("DrugAddictIdent").value;
    AddictOrigin = document.getElementById("DrugAddictOrigin").value;
    retValue = SODC.IDIS.DrugAddict.ListViewDrugAddict.GetHtml(belongsite, Addictcode, AddictName, AddictIdent, AddictOrigin, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("listdrugpersonscontent").innerHTML = retValue;
}
function ShowClientUpdateUrlForm(DrugAddictId, belongsite, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    Url = SODC.IDIS.DrugAddict.ListViewDrugAddict.GetShowUpdateForm(DrugAddictId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.open(Url, "_blank");
    //window.showModalDialog(Url, null, 'dialogHeight: 800px; dialogWidth: 950px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    RealFilterFunc(belongsite, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript);
//    retValue = SODC.IDIS.DrugAddict.ListViewDrugAddict.GetUpdateAddictForm(DrugAddictId).value;
//    if (retValue.indexOf("ERROR") != -1) {
//        alert(retValue);
//        return;
//    }
//    document.getElementById("divupdateaddictcontent").innerHTML = "";
//    document.getElementById("divupdateaddictcontent").innerHTML = retValue;
}
function ShowClientViewdetailsForm(DrugAddictId,belongsite, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    Url = SODC.IDIS.DrugAddict.ListViewDrugAddict.GetShowDetailsForm(DrugAddictId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.open(Url, "_blank");
    RealFilterFunc(belongsite, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript);
//    retValue = SODC.IDIS.DrugAddict.ListViewDrugAddict.GetViewDetailsForm(DrugAddictId).value;
//    if (retValue.indexOf("ERROR") != -1) {
//        alert(retValue);
//        return;
//    }
//    document.getElementById("divviewdetailscontent").innerHTML = "";
//    document.getElementById("divviewdetailscontent").innerHTML = retValue;
}
function ShowClientUpdateUrlFromviewform(DrugAddictId) {
    Url = SODC.IDIS.DrugAddict.ViewDetailsDrugAddict.GetShowUpdateForm(DrugAddictId).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.open(Url,"_self");
}
function showhidedivstatus(id1, id2, value) {
    var e1 = document.getElementById(id1);
    var e2 = document.getElementById(id2);
    if (value == "2") {
        e1.style.display = 'block';
        e2.style.display = 'none';
    }

    else {
        if (value == "3") {
            e1.style.display = 'block';
            e2.style.display = 'block';
        }
        else {
            e1.style.display = 'none';
            e2.style.display = 'none';
        }
    }
}
function ClientStatus() {
    alert("Chuyên mục này đang xây dựng!");
    return;
}

function UploadNewImage() {
    Url = SODC.IDIS.DrugAddict.AddNewDrugAddict.GetUpdateImageUrl().value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
}

function ClientAddHtml()
{
    belongSite=document.getElementById("drpSelectSite").options[document.getElementById("drpSelectSite").selectedIndex].value;
    Url = SharepointPortal.WebParts.Html.Html.GetAddNewUrl(belongSite).value;
    window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 840px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    WorkflowStatusIndex=document.getElementById("divSelectWorkflowStatus").selectedIndex;
    WorkflowStatus=document.getElementById("divSelectWorkflowStatus").options[WorkflowStatusIndex].value;
    PageIndex=document.getElementById("divSelectPage").selectedIndex;
    value=SharepointPortal.WebParts.Html.Html.GetHtml(WorkflowStatus,PageIndex).value;
    if(value.indexOf("ERROR")==-1)
    {
        document.getElementById("divHtmlContent").innerHTML=value;
    }
    else
    {
        alert(value);
    }
}

function ClientSaveAddHtml()
{
    belongSite=document.getElementById("txtBelongSite").value;
    language = document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    Alias = document.getElementById("txtAlias").value;
    Subject=document.getElementById("txtSubject").value;
    var instanceName="ctl04";
    var oEditor = FCKeditorAPI.GetInstance(instanceName) ;
    bodyText= oEditor.GetXHTML( true );
    value = SharepointPortal.WebParts.Html.AddHtml.ServerSideAddHtml(belongSite, language, Alias, Subject, bodyText).value;
    if(value.indexOf("ERROR")!=-1)
    {
        alert(value);
        return;
    }
    window.close();
}

function ClientSaveHtml(HtmlId)
{
    language = document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    Alias = document.getElementById("txtAlias").value;
    Subject=document.getElementById("txtSubject").value;
     if(FCKeditorAPI==null)
    {
    
        alert(SharepointPortal.WebParts.Html.UpdateHtml.GetLoadDataMsg().value);
        return;
    }
    var instanceName="ctl04";
    var oEditor = FCKeditorAPI.GetInstance(instanceName) ;
    
    if(oEditor==null)
    {
        alert(SharepointPortal.WebParts.Html.UpdateHtml.GetLoadDataMsg().value);
        return;
    }
    bodyText= oEditor.GetXHTML( true );
    value = SharepointPortal.WebParts.Html.UpdateHtml.ServerSideHtml(language, HtmlId, Alias, Subject, bodyText).value;
    if(value.indexOf("ERROR")!=-1)
    {
        alert(value);
        return;
    }
    retValue=SharepointPortal.WebParts.Html.UpdateHtml.GetInfoSaveMsg(language).value;
    alert(retValue);
    window.close();
}

function RunFilter()
{
    document.getElementById("divProcessing").innerHTML=SharepointPortal.WebParts.Html.Html.GetProcessingText().value;
    setTimeout("RealRunFilter()",10);
}


function RealRunFilter()
{
    WorkflowStatusIndex=document.getElementById("divSelectWorkflowStatus").selectedIndex;
    WorkflowStatus="";
    if(WorkflowStatusIndex!=-1)
    {
        WorkflowStatus=document.getElementById("divSelectWorkflowStatus").options[WorkflowStatusIndex].value;
    }
    
    belongSite=document.getElementById("drpSelectSite").options[document.getElementById("drpSelectSite").selectedIndex].value;
    PageIndex=document.getElementById("divSelectPage").selectedIndex;
    if(PageIndex<0)PageIndex=0;
    value=SharepointPortal.WebParts.Html.Html.GetHtml(belongSite, WorkflowStatus,PageIndex).value;
    if(value.indexOf("ERROR")!=-1)
    {
        document.getElementById("divProcessing").innerHTML="";
        alert(value);
        return;
    }
    document.getElementById("divProcessing").innerHTML="";
    document.getElementById("divHtmlContent").innerHTML=value;
}


function ClientDeleteHtml(HtmlId)
{
    if(confirm(SharepointPortal.WebParts.Html.Html.GetConfirmMsg().value)==false)
    {
        return;
    }
    value=SharepointPortal.WebParts.Html.Html.ServerSideDeleteHtml(HtmlId).value;
    if(value.indexOf("ERROR")!=-1)
    {
        alert(value);
        return;
    }
    alert(SharepointPortal.WebParts.Html.Html.GetDeleteOkMsg().value);
    WorkflowStatusIndex=document.getElementById("divSelectWorkflowStatus").selectedIndex;
    WorkflowStatus=document.getElementById("divSelectWorkflowStatus").options[WorkflowStatusIndex].value;
    PageIndex=document.getElementById("divSelectPage").selectedIndex;
    value=SharepointPortal.WebParts.Html.Html.GetHtml(WorkflowStatus,PageIndex).value;
    document.getElementById("divHtmlContent").innerHTML=value;
}

function ShowUpdateHtmlForm(HtmlId)
{
    Url=SharepointPortal.WebParts.Html.Html.GetUpdateHtmlUrl(HtmlId).value;
    window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 840px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    WorkflowStatusIndex=document.getElementById("divSelectWorkflowStatus").selectedIndex;
    WorkflowStatus=document.getElementById("divSelectWorkflowStatus").options[WorkflowStatusIndex].value;
    PageIndex=document.getElementById("divSelectPage").selectedIndex;
 
    value=SharepointPortal.WebParts.Html.Html.GetHtml(WorkflowStatus,PageIndex).value;
    if(value.indexOf("ERROR")==-1)
    {
        document.getElementById("divHtmlContent").innerHTML=value;
    }
    else
    {
        alert(value);
    }
}


function DetectHtmlBody(HtmlId)
{
    language=document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    retValue = SharepointPortal.WebParts.Html.UpdateHtml.GetSubject(language,HtmlId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    document.getElementById("txtSubject").value = retValue;
    
    var instanceName="ctl02";
    var oEditor = FCKeditorAPI.GetInstance(instanceName) ;
    retValue=SharepointPortal.WebParts.Html.UpdateHtml.GetBody(language,HtmlId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    oEditor.SetHTML(retValue);
    
}


function ClientPublishingHtml(HtmlId)
{
    if(confirm(SharepointPortal.WebParts.Html.Html.GetConfirmPublishingMsg().value)==false)
    {
        return;
    }
    retValue = SharepointPortal.WebParts.Html.Html.ServerSidePublishing(HtmlId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    alert(retValue);
}




function ClientUnPublishingHtml(HtmlId)
{
    if(confirm(SharepointPortal.WebParts.Html.Html.GetConfirmUnPublishingMsg().value)==false)
    {
        return;
    }
    retValue = SharepointPortal.WebParts.Html.Html.ServerSideUnPublishing(HtmlId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    alert(retValue);
}

function DoSyncAll(belongSite)
{
    if(confirm(SharepointPortal.WebParts.Html.Html.GetConfirmSyncAllMsg().value)==false)
    {
        return;
    }
    document.getElementById("divProcessing").innerHTML=SharepointPortal.WebParts.Html.Html.GetProcessingText().value;
    setTimeout("RealDoSyncAll('"+belongSite+"')",10);
}



function RealDoSyncAll(belongSite)
{
    retValue=SharepointPortal.WebParts.Html.Html.SyncToServer(belongSite).value;
    document.getElementById("divProcessing").innerHTML="";
    alert(retValue);
}
